package com.ymttest.business.data;

import java.io.IOException;
import java.util.ArrayList;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.ymt.base.YmatouBaseCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymttest.utils.TestDataManager;


public class Data201703 {

	public static void main(String[] args) throws JSONException, ClientProtocolException, IOException {
		//产线压测数据准备
		//获取products
		String url="http://app.ymatou.com/api/live/list";
		TestDataManager.appendFileToLine("liveandseller.dat","liveid,sellerid");
		for (int i=0;i<100;i++) {
			JsonArray list = new JsonArray();
			YmatouEasyCall ec=new YmatouEasyCall(url, "POST", "JSON");
			ec.addHeader("sign", "b0c3932c3445839f95960c812672c800");
			ec.setData("{\"filter\":[],\"pageindex\":"+i+"}");
			ec.callService();
			list=ec.getJsonObject().get("list").getAsJsonArray();
			for (JsonElement jsonElement : list) {
				JsonArray productslist = jsonElement.getAsJsonObject().get("products").getAsJsonArray();
				for (JsonElement jsonElement2 : productslist) {
					TestDataManager.appendFileToLine("productid.dat",jsonElement2.getAsJsonObject().get("id").getAsString());
			}
//				TestDataManager.appendFileToLine("liveandseller.dat",jsonElement.getAsJsonObject().get("live").getAsJsonObject().get("id").toString()+","+jsonElement.getAsJsonObject().get("sellerInfo").getAsJsonObject().get("id").toString());
//				TestDataManager.appendFileToLine("liveandseller.dat",jsonElement.getAsJsonObject().get("sellerInfo").getAsJsonObject().get("id").toString());
			}
			
		}
	}
}
